# -*- coding: utf-8 -*-
ES_INDEX_NAME = "yj_search"
ES_DOC_CHOICE = "choice"
ES_DOC_UNIVERSAL = "universal"
ES_DOC_MIX = ["choice", "universal"]

fuzzy_query = """{
    "query": {"match": {"content": "%s"}},
    "highlight": {
        "pre_tags": ["<font color='red'>"],
        "post_tags": ["</font>"],
        "fields": {
            "content": {"number_of_fragments" : 0}
        }
    }
}"""

fuzzy_query_with_q_type = """{
  "query": {
    "bool": {
      "should": [
        { "match": { "content": "%s" }}
      ],
      "must": [
        { "term": { "subjectid": "%s" }},
        { "term": { "name": "1" }}
        ],
      "must_not": [
        {"term": {"teachervisible" : 0}},
        {"term": {"is_paper" : 1}}
      ]
    }
  },
  "highlight": {
        "pre_tags": ["<font color='red'>"],
        "post_tags": ["</font>"],
        "fields": {
            "content": {"number_of_fragments" : 0}
        }
    }
}"""


fuzzy_query_with_subjectid = """{
  "query": {
    "bool": {
      "should": [
        { "match": { "content": "%s" }},
        { "match": { "answer": "%s" }}
      ],
      "must": [
        { "term": { "subjectid": "%s" }},
        { "term": { "name": "%s" }}
        ],
      "must_not": [
        {"term": {"teachervisible" : 0}},
        {"term": {"is_paper" : 1}}
      ]
    }
  },
  "highlight": {
        "pre_tags": ["<font color='red'>"],
        "post_tags": ["</font>"],
        "fields": {
            "content": {"number_of_fragments" : 0},
            "answer": {"number_of_fragments" : 0}
        }
    }
}"""

mfuzzy_query = """{
    "query": {
        "multi_match": {
            "query": "%s",
            "type": "best_fields",
            "fields":["content", "answer"]
        }
    },
    "highlight": {
        "pre_tags": ["<font color='red'>"],
        "post_tags": ["</font>"],
        "fields": {
            "content": {"number_of_fragments" : 0},
            "answer": {"number_of_fragments" : 0}
        }
    }
}"""

mapping_query = """
{
    "%s": {
             "_all": {
            "analyzer": "%s",
            "search_analyzer": "%s",
            "term_vector": "no",
            "store": "false"
        },
        "properties": {
            "%s": {
                "type": "text",
                "analyzer": "%s",
                "search_analyzer": "%s",
                "include_in_all": "true",
                "boost": 8
            }
        }
    }
}

"""


# "content": {"fragment_size" : 300, "number_of_fragments" : 5}
# fragment_size highlight的字符数
# number_of_fragments 检索出来的片段数
# If the number_of_fragments value is set to 0 then no fragments are produced,
# instead the whole content of the field is returned, and of course it is highlighted.
# This can be very handy if short texts (like document title or address)
# need to be highlighted but no fragmentation is required. Note that fragment_size is ignored in this case.
